<%@ Page Language="C#" Inherits="IBuyAdventure.PageBase" src="components/stdpage.cs" %>
<%@ Register TagPrefix="IBA" TagName="Header" Src="UserControl\Header.ascx" %>
<%@ Register TagPrefix="IBA" TagName="Footer" Src="UserControl\Footer.ascx" %>
<%@ Register TagPrefix="IBA" TagName="Categories" Src="UserControl\Categories.ascx" %>
<%@ Register TagPrefix="Wrox" Namespace="WroxControls" Assembly="RatingMeter" %>
<%@ Import Namespace="System.Data" %>
<%@ OutputCache Duration="600" VaryByParam="ProductCode" %>
 
<HTML>
  <HEAD>
    <TITLE>IBuyAdventure Catalog</TITLE>
  </HEAD>
  
  <script language="C#" runat="server">

      void Page_Load(Object sender, EventArgs e) {

         // User business object to fetch category products and databind
         // it to a <asp:datalist> control
                 
         DataSet productDetails;
         IBuyAdventure.ProductsDB inventory = new IBuyAdventure.ProductsDB(getConnStr());         

         productDetails = inventory.GetProduct(Request.QueryString["ProductCode"] );
         MyList.DataSource = productDetails;
         MyList.DataBind();

         SectionTitle.InnerHtml = (string) productDetails.Tables[0].Rows[0]["ProductName"] + " Details";
      }
      void DataList_ItemCreated(Object sender , DataListItemEventArgs e ) {

		
		DataRowView myRowView;
		DataRow myRow;
		
		myRowView = (DataRowView) e.Item.DataItem;
		myRow = myRowView.Row;
		
		if  ( (int) myRow["OnSale"] == 0 ) 
			e.Item.FindControl("saleItem").Visible = false;
		
      }

  </script>

  <BODY BACKGROUND="images/back_sub.gif"> 
    <form runat="server">
    <FONT FACE="Verdana, Arial, Helvetica" SIZE=2>

      <TABLE BORDER=0>
        
        <tr>
          <td colspan=5>
            <IBA:Header id="Header" runat="server"/>
          </td>
        </tr>

        <TR>
          <TD ROWSPAN=5 ALIGN=LEFT VALIGN=TOP>

            <IBA:Categories id="Categories" runat="server"/>
            
            <br><br><br>
            
           
          </TD>
          
          <TD valign=top align=center>
          
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <h3 id="SectionTitle" runat="server" />
          
            <asp:datalist id="MyList" BorderWidth=0 RepeatDirection=horizontal RepeatColumns=2 OnItemCreated="DataList_ItemCreated" runat="server">
          
              <itemtemplate>
              
                <table>
                  <tr>
                  
                    <td align=right valign=top width=150>
                       <IMG SRC='<%# DataBinder.Eval(Container.DataItem, "ProductImageURL","images/{0}") %>'>
                    </td>
                  
                     
                    <td align=left valign=top>
                      <font size=2>
                        <B>Information:</B><BR><BR>
                        <%#DataBinder.Eval(Container.DataItem, "ProductDescription")%><BR>

                        <BR>
                        
                          <%#DataBinder.Eval(Container.DataItem, "ProductCode")%>
                        </a>
              <BR> 
                        <BR>
                        
                          Product first introduced <%#DataBinder.Eval(Container.DataItem, "ProductIntroductionDate","{0:d}" )%>
                        <BR>
                        <BR> 
                        <span id="saleItem" runat="server">
                        &nbsp; <img src="images/saleTag1.gif"  >
                          <asp:label id="lab" runat="server" />
                        </span>
                        <B><%#DataBinder.Eval(Container.DataItem, "UnitPrice", "{0:C}")%></B>    
                        
                        <br><br>
                        
                        <a href='ShoppingCart.aspx?ProductCode=<%#DataBinder.Eval(Container.DataItem, "ProductCode")%>'>
                          <img src="images/order.gif" WIDTH="55" HEIGHT="15" ALT="Order" BORDER=0>
                        </a>

                      <BR><BR>
                       <Wrox:RatingMeter runat="server" Score=<%#(double)DataBinder.Eval(Container.DataItem, "Rating")%> Votes=1 MaxRating=5 CellWidth=51 CellHeight=10 />
                      </font>                      
                    </td>  
                  
                  </tr>
                </table>
              
              </itemtemplate>
          
            </asp:datalist>
            
          </TD>
        </TR>
        <TR><td>       <IBA:Footer runat="server" />
      </TABLE>
    </FONT>
    </form>
  </BODY>
</HTML>
